<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <title>企业资料</title>
    <link rel="stylesheet" href="../../../public/dist/css/layui.css">
    <link rel="stylesheet" href="../../../css/enterprisedata.css">
    <link rel="stylesheet" href="../../../public/font/iconfont.css">
</head>


<body>
    <!-- 查询 -->
    <form class="layui-form layui-form-pane" action="" lay-filter="example" id="example">
        <div class="select">
            <div class="select-left">
                <input type="text" class="layui-input select-item-input" name="imgpath1" id="imgpath1"
                    style="display: none">
                <input type="text" class="layui-input select-item-input" name="imgpath2" id="imgpath2"
                    style="display: none">

                <!--  style="display: none" -->
                <div class="select-item">
                    <div class="select-item-text">
                        公司代号*
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s1" id="s1">
                </div>
                <div class="select-item">
                    <div class="select-item-text">
                        中文名称*
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s2" id="s2">
                </div>



                <!-- <div class="select-item">
                    <div class="select-item-text">
                        中文地址*
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s3" id="s3">
                </div> -->

                <div class="select-item">
                    <div class="select-item-text">
                        电话号码*
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s4" id="s4">
                </div>

                <div class="select-item">
                    <div class="select-item-text">
                        传真号码
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s5" id="s5">
                </div>

                <div class="select-item">
                    <div class="select-item-text">
                        网址
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s6" id="s6">
                </div>

                <div class="select-item">
                    <div class="select-item-text">
                        负责人*
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s7" id="s7">
                </div>
                <div class="select-item">
                    <div class="select-item-text">
                        所在地区*
                    </div>
                    <div class="layui-inline-sel" style="display: flex;">
                        <select name="country" lay-filter="aihao" id='state'>
                            <option value="0086">中国</option>
                        </select>
                    </div>
                </div>
                <div class="select-item">
                    <div class="layui-inline">
                        <div class="layui-inline-sel" style="display: flex;">

                            <select name="province" lay-filter="province" class="province" id='province' name="s8">
                                <option value="">省</option>
                            </select>

                        </div>
                    </div>
                </div>
                <div class="select-item">
                    <div class="layui-inline">
                        <div class="layui-inline-sel" style="display: flex;">

                            <select name="city" lay-filter="city" class="city" id='city' name="s9">
                                <option value="">市</option>
                            </select>


                        </div>
                    </div>
                </div>
                <div class="select-item">
                    <div class="layui-inline">
                        <div class="layui-inline-sel" style="display: flex;">


                            <select name="area" lay-filter="area" class="area" id='district' name="s10">
                                <option value="">区</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="select-item">
                    <div class="select-item-text">
                        详细地址*
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s11" id="s11">
                </div>

                <div class="select-item">
                    <div class="select-item-text">
                        邮政编码
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s12" id="s12">
                </div>

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        电子邮件
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s13" id="13">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        行业
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s14" id="14">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        官方网址
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s15" id="15">
                </div> -->


                <!-- <div class="select-item" style="width:100%;">
                    <div class="select-item-text">
                        备注
                    </div>
                    <textarea id="" class="select-textarea" name="s16" id="s16"></textarea>
                </div> -->
                <!-- <div class="select-item layui-form-item">
                    <input type="checkbox" title="启用客户分权" lay-skin="primary" name="s17">
                </div> -->
                <!-- <div class="select-item layui-form-item">
                    <input type="checkbox" title="启用供应商分权" lay-skin="primary" name="s18">
                </div> -->


                <!-- <div class="select-item">
                    <div class="select-item-text">
                        数字小数位数
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s19">
                </div> -->


                <!-- <div class="select-item">
                    <div class="select-item-text">
                        单价小数位数
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s19">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        金额小数位数
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s20">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        商户号
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s21">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        金融平台账号
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s22">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        金融平台密码
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s23">
                </div> -->

                <!-- <div class="select-item layui-form-item">
                    <input type="checkbox" title="是否发送下一步信息" lay-skin="primary" name="s24">
                </div> -->

                <!-- <div class="select-item">
                    <div class="select-item-text">
                        业务类型
                    </div>
                    <input type="text" class="layui-input select-item-input" name="s25">
                </div> -->

                <!-- <div class="select-item layui-form-item">
                    <input type="checkbox" title="接单引用对方物料基础数据" lay-skin="primary" name="s26">
                </div> -->


                <!-- <div class="select-item layui-form-item">
                    <input type="checkbox" title="启用物料类别分权" lay-skin="primary" name="s27">
                </div> -->
            </div>



            <div class="select-right">
                <!-- <div class="select-btn">
                    查询
                </div>
                <div class="select-btn">
                    清除
                </div> -->
                <!-- <select name="" id="" class="select-item-select2"  lay-ignore>
                    <option value="">期间</option>
                    <option value="">期间</option>
                    <option value="">期间</option>
                </select> -->
            </div>
        </div>


        <div class="switch">
            <div class="switch-nav">
                <div class="item item-this">
                    执照信息
                </div>

                <div class="item">
                    企业二维码
                </div>
            </div>
            <div class="switch-content switch-content-this" id='switch1'>
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img upload-img" id="demo1">
                        <p id="demoText1"></p>
                        <div class="uploadimg-txt">营业执照</div>
                    </div>
                </div>

                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test2">上传图片</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img upload-img" id="demo2">
                        <p id="demoText2"></p>
                        <div class="uploadimg-txt">法人身份证</div>
                    </div>
                </div>
            </div>




            <div class="switch-content" id='switch5'>
                <div class="switch-content-title">手机与企业形成协同关系</div>
                <div class="layui-upload">
                    <!-- <button type="button" class="layui-btn" id="test1">上传图片</button> -->
                    <div class="layui-upload-list">
                        <img class="layui-upload-img upload-img upload-img-code" id="demo3">
                        <!-- <p id="demoText1"></p> -->
                        <div class="uploadimg-txt">二维码</div>
                    </div>
                </div>


            </div>
        </div>



        <div class="layui-form-item" style="margin: 0 auto;display: flex;justify-content: center;margin-top: 20px;">
            <div class="layui-input-block">
                <button class="layui-btn submit" lay-submit="">立即提交</button>
                <!-- <button type="reset" class="layui-btn cancels">取消</button> -->
            </div>
        </div>
    </form>

</body>
<script src="../../../public/dist/layui.js" charset="utf-8"></script>
<script src="../../../js/common/jquery.min.js"></script>
<script src="../../../js/common/api.js"></script>
<script>
    layui.use(['table', 'laypage', 'laydate', 'upload', 'form'], function () {

        var table = layui.table;
        var laydate = layui.laydate;
        var laypage = layui.laypage
            , form = layui.form

            , layer = layui.layer;
        //执行一个laydate实例
        laydate.render({
            elem: '#date1' //指定元素
        });
        laydate.render({
            elem: '#date2' //指定元素
        });


        var $ = layui.jquery
            , upload = layui.upload;
        //tabs
        var switchNav = document.querySelectorAll('.switch-nav .item');
        var switchContent = document.querySelectorAll('.switch-content');
        for (var i = 0; i < switchNav.length; i++) {
            (function (i) {
                switchNav[i].addEventListener('click', function () {
                    document.querySelector('.switch-nav .item-this').classList.remove('item-this');
                    document.querySelector('.switch-content-this').classList.remove('switch-content-this');
                    switchNav[i].classList.add('item-this');
                    switchContent[i].classList.add('switch-content-this');

                })
            })(i)
        }

        //省市区三级联动
        getProvince();
        function getProvince(e) {
            handleAjax('enterprise/getProvincecity', { parentid: e }, "GET").done(function (resp) {


                $.each(resp.list, function (index, item) {
                    $('.province').append(new Option(item.fullName, item.code)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                return
            }).fail(function (err) {
                console.log(err)

            });
        }
        function getCity(e) {
            handleAjax('enterprise/getProvincecity', { parentid: e }, "GET").done(function (resp) {
                $.each(resp.list, function (index, item) {
                    $('.city').append(new Option(item.fullName, item.code)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                return
            }).fail(function (err) {
                console.log(err)

            });
        }
        function getArea(e) {
            handleAjax('enterprise/getProvincecity', { parentid: e }, "GET").done(function (resp) {


                $.each(resp.list, function (index, item) {
                    $('.area').append(new Option(item.fullName, item.code)); // 下拉菜单里添加元素
                });
                layui.form.render("select");
                return
            }).fail(function (err) {
                console.log(err)

            });
        }
        form.on('select(province)', function (data) {
            console.log(data.value); //得到被选中的值
            document.querySelector('.city').innerHTML = '<option value="">市</option>';
            document.querySelector('.area').innerHTML = '<option value="">区</option>';
            getCity(data.value);
        });
        form.on('select(city)', function (data) {
            console.log(data.value); //得到被选中的值
            document.querySelector('.area').innerHTML = '<option value="">区</option>';
            getArea(data.value);
        });

    });



</script>
<script>
    var dataId = null;
    layui.config({
        base: '../../../js/module/'
    }).use(['Tool', 'form', 'layedit', 'laydate', "serviceTools", "upload"], function () {
        layui.Tool.init();
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , serviceTools = layui.serviceTools;
        var obj1 = {};




        handleAjax('coa/getCoBusinessInfo', {}, 'GET').done(function (resp) {
            console.log(resp.list[0])
            console.log(777)
            var obj = {};
            obj = resp.list[0];
            $('#state').val(obj.country).trigger("change");
            $('#s11').val(obj.chnAddr);
            $('#s2').val(obj.chnName);
            $('#city').val(obj.city);
            $('#state').val(obj.country);
            $('#district').val(obj.district);
            $('#s13').val(obj.eMail);
            $('#s1').val(obj.entityId);
            $('#s5').val(obj.fax);
            $('#s14').val(obj.industry);
            $('#s7').val(obj.principal);
            $('#s16').val(obj.remark);
            $('#province').val(obj.state);
            $('#s4').val(obj.telephone);
            $('#s6').val(obj.utl);
            $('#s12').val(obj.zipcode);
            // $('#s1').val(obj.entityId)
            // $('#s2').val(obj.chnName)
            // $('#s4').val(obj.telephone)
            // $('#s7').val(obj.artificalPerson)
            // $('#s11').val(obj.custAdd)
            // $('#demo1').attr('src', obj.licenseImage)
            // $('#demo2').attr('src', obj.idCardImageOne)
            obj1.id = obj.id
            return
        })








        //指定允许上传的文件类型
        layui.upload.render({
            elem: '#test1'
            , url: base + "common/upload"
            , accept: 'file'
            , exts: 'doc|docx|pdf|png|jpg'
            , field: "file"
            , headers: { Authorization: 'Bearer' + ' ' + sessions }
            , done: function (res) {
                console.log(res.list[0]);
                var filePath = res.list[0];
                filePath = filePath.substring(0, filePath.length);
                document.querySelector("#imgpath1").value = filePath;
                $('#demo1').attr('src', filePath)
            }
        });


        //指定允许上传的文件类型
        layui.upload.render({
            elem: '#test2'
            , url: base + "common/upload"
            , accept: 'file'
            , exts: 'doc|docx|pdf|png|jpg'
            , field: "file"
            , headers: { Authorization: 'Bearer' + ' ' + sessions }
            , done: function (res) {
                var filePath = res.list[0];
                filePath = filePath.substring(0, filePath.length);
                document.querySelector("#imgpath2").value = filePath;
                $('#demo2').attr('src', filePath)
            }
        });




        $('.submit').click(function () {
            obj1.chnAddr = $('#s11').val();
            obj1.chnName = $('#s2').val();
            obj1.city = $('#city').val();
            obj1.country = $('#state').val();
            obj1.district = $('#district').val();
            obj1.eMail = $('#s13').val();
            obj1.entityId = $('#s1').val();
            obj1.fax = $('#s5').val();
            // obj1.id = $('#s').val();
            obj1.industry = $('#s14').val();
            obj1.principal = $('#s7').val();
            obj1.remark = $('#s16').val();
            obj1.state = $('#province').val();
            obj1.telephone = $('#s4').val();
            obj1.utl = $('#s6').val();
            obj1.zipcode = $('#s12').val();

            console.log(obj1)
            console.log(111)

            handleAjax('coa/updateCoBusinessInfo', obj1, 'POST').done(function (res) {
                console.log(res)
            })

        })
    })




</script>

</html>